<?
	/* Se asegura que el archivo es incluido por el index */
		//defined( 'LOAD_MODULE_ACTION' ) or die( 'No esta permitido el acceso directo a ' . __FILE__ );
	/* Cuando se hace el include del archivo automaticamente crea un objeto y lo guarda en una variable temporal */
		$this->oTmpObject = new Domicilio_frm( $this );
	class Domicilio_frm extends Frm
	{
	function getValue()
		{
			return $this->aFields['ncDomicilio']->getValue();
		}
	function makeMapa()
		{
			// Arma el Mapa
			$oMapa = new Mapa(740, 470, 4);  
			
			$oMapa->setShowCoord();
			$oMapa->setOnDblClick('o=document.getElementById(\'nX\');o.value= mapX(event); o=document.getElementById(\'nY\'); o.value=mapY(event); closePopup();');
			
			$nX= getParam('nX');
			$nY= getParam('nY');
			if ( !$nX || !$nY )
			{
				$ncDomicilio = getParam('ncDomicilio');
				if ( $ncDomicilio  )
				{
					$cSql = "SELECT  Dom.nX, Dom.nY, ncUbicacion FROM atDomicilio as Dom WHERE ncDomicilio =  $ncDomicilio ";
					list ( $nX, $nY , $ncUbicacion )  = $this->oDatabase->getArray($cSql );
				}
			}
			if ( !$nX > 0 || !$nY  > 0 )
			{
				$aUbicaciones = array( 601=> array(5546,3957), 602=> array(3611,4922), 603=> array(3207,5431), 604=> array(1792,4979), 605=> array(5690,5701), 606=> array(1554,5496), 607=> array(3095,4502), 608=> array(3895,4212),  609=> array(4870,4883), 610=> array(6115,5121), 611=> array(5160,5407), 612=> array(2327,5323), 613=> array(3946,3481), 614=> array(4523,3068), 615=> array(5241,1928), 616=> array(4369,1932), 
					617=> array(5300,2812), 618=> array(2594,5853), 619=> array(2329,3793), 620=> array(6352,5895), 621=> array(4391,5947), 622=> array(3965,2627), 623=> array(3313,3879), 624=> array(2499,4528), 625=> array(5113,4307), 626=> array(2195,6224), 627=> array(3511,6076), 628=> array(3056,6316), 629=> array(6634,4945), 630=> array(2791,5031), 631=> array(2845,5981), 632=> array(2150,5713), 
					633=> array(4337,2868), 634=> array(5533,2146), 635=> array(4532,4753), 636=> array(5473,3590), 637=> array(5962,3308), 638=> array(4891,3969), 639=> array(3037,1819), 640=> array(4642,2427), 641=> array(5443,4785), 642=> array(6353,3972), 643=> array(5708,2382), 644=> array(2769,1473), 645=> array(4896,3709), 646=> array(2811,3126), 647=> array(5626,4967), 648=> array(5696,4451) );
				$oMapa->setCenter($aUbicaciones[$ncUbicacion][0], $aUbicaciones[$ncUbicacion][1]);
			}	else
			{
				$oMapa->addPoint( $nX, $nY , '', 1 );
				$oMapa->setCentePoint();
			}
		?>
			<div style="border-top: 1px solid #EEEEEE; border-left: 1px solid #EEEEEE"><? 	$oMapa->make(); ?></div>
			<script>loadMap();</script>
			<?
		}
	function getFieldValue( $cField )
		{
			return $this->aFields[$cField]->getValue();
		}
	function getDescription( $ncDomicilio = '')
		{
			// Si viene un Domicilio Busca los datos
			if ( $ncDomicilio  )
			{
				$this->setValue( $ncDomicilio );
			}
			$cReturn = '';
			switch( $this->aFields['nTipoDomicilio']->getValue() )
			{
				case DOMICILIO_URBANO:
					if ( $this->aFields['cCalleInterseccion']->getValue() )
					{
						$cReturn = $this->aFields['cCalle']->getValue() ;
						if ( $this->aFields['nNumero']->getValue() ) $cReturn .= ' al ' . $this->aFields['nNumero']->getValue();
						if ( $this->aFields['cTorre']->getValue() ) $cReturn .= ' Torre ' . $this->aFields['cTorre']->getValue();
						if ( $this->aFields['cPiso']->getValue() ) $cReturn .= ' Piso ' . $this->aFields['cPiso']->getValue();
						if ( $this->aFields['cDepto']->getValue() ) $cReturn .= ' ' . $this->aFields['cDepto']->getValue();
						$cReturn .= ' y ' . $this->aFields['cCalleInterseccion']->getValue();
					} else
					{
						$cReturn = $this->aFields['cCalle']->getValue() ;
						if ( $this->aFields['nNumero']->getValue() ) $cReturn .= ' ' . $this->aFields['nNumero']->getValue();
						if ( $this->aFields['cTorre']->getValue() ) $cReturn .= ' Torre ' . $this->aFields['cTorre']->getValue();
						if ( $this->aFields['cPiso']->getValue() ) $cReturn .= ' Piso ' . $this->aFields['cPiso']->getValue();
						if ( $this->aFields['cDepto']->getValue() ) $cReturn .= ' ' . $this->aFields['cDepto']->getValue();
					}
					break;
				case DOMICILIO_RURAL:
					$cReturn .= $this->aFields['ncRuta']->getValue() . ' ' . $this->aFields['nKilometro']->getValue();
					break;
				case DOMICILIO_ZONA:
					$cCalleA =  $this->aFields['cCalleA']->getValue();
					$cCalleB = $this->aFields['cCalleB']->getValue() ;
					$cCalleC = $this->aFields['cCalleC']->getValue() ;
					$cCalleD = $this->aFields['cCalleD']->getValue() ;
					if ( $cCalleA && $cCalleB && $cCalleC && $cCalleD )  $cReturn = $cCalleA . ', ' . $cCalleB . ', ' . $cCalleC . ' y  ' .$cCalleD;
					elseif ( $cCalleA && $cCalleB && $cCalleC )  $cReturn = $cCalleA . ', ' . $cCalleB . ' y ' . $cCalleC ;
					elseif ( $cCalleA && $cCalleB  )  $cReturn = $cCalleA . ' y ' . $cCalleB ;
					else $cReturn = $cCalleA . ', ' . $cCalleB . ', ' . $cCalleC . ' y  ' .$cCalleD;
					break;
				case DOMICILIO_POSTAL:
					$cReturn .= ' PBox: ' . $this->aFields['cCasilla']->getValue();
					break;
				case DOMICILIO_SUBURBANO:
					$cReturn .= $this->aFields['cDescripcion']->getValue();
					break;
			}
			return $cReturn;
		}
	function getUbicacion()
		{
			return $this->aFields['ncUbicacion']->getDescription() ;
		}
	function Domicilio_frm( &$oModule )
		{
			$this->Frm( $oModule );
	// Crea los Campos de Edicion
			$this->aFields['ncDomicilio']     = new InputNumber( 'Codigo', 'ncDomicilio' );
			$this->aFields['nTipoDomicilioAnterior']     = new InputNumber( '', 'nTipoDomicilioAnterior' );
			$this->aFields['ncPais']          = new InputList( 'Pais', 'ncPais' );
			$this->aFields['ncUbicacion']     = new InputLookUp( 'Ubicacion', 'ncUbicacion' );
			$this->aFields['cPostal']         	= new InputText( 'Postal', 'cPostal' );
			$this->aFields['cPostales']         = new InputList( '', 'cPostales' );
			$this->aFields['cPrefijoTelefono']= new InputText( 'Prefijo', 'cPrefijoTelefono' );
			$this->aFields['cTelefono']       = new InputMultiple( 'Telefono', 'cTelefono' );
			$this->aFields['cFax']       	= new InputMultiple( 'Fax', 'cFax' );
			$this->aFields['cCalle']          = new InputText( 'Calle', 'cCalle' );
			$this->aFields['cCalleA']          = new InputText( 'CalleA', 'cCalleA' );
			$this->aFields['cCalleB']          = new InputText( 'CalleB', 'cCalleB' );
			$this->aFields['cCalleC']          = new InputText( 'CalleC', 'cCalleC' );
			$this->aFields['cCalleD']          = new InputText( 'CalleD', 'cCalleD' );
			$this->aFields['cCalleInterseccion'] = new InputLookUp( 'Calle interseccion', 'cCalleInterseccion' );
			$this->aFields['nNumero']         = new InputNumber( 'Nro', 'nNumero' );
			$this->aFields['cTorre']          = new InputText( 'Torre', 'cTorre' );
			$this->aFields['cPiso']           = new InputText( 'Piso',  'cPiso' );
			$this->aFields['cDepto']          = new InputText( 'Depto', 'cDepto' );
			$this->aFields['cDescripcion']    = new InputText( 'Descripcion', 'cDescripcion' );
			$this->aFields['cCasilla']    		= new InputText( 'Casilla', 'cCasilla' );
			$this->aFields['nKilometro']      = new InputNumber( 'KM', 'nKilometro' );
			$this->aFields['ncRuta']          = new InputList( 'Ruta', 'ncRuta' );
			$this->aFields['nTipoDomicilio']  = new InputList( 'Tipo', 'nTipoDomicilio' );
			$this->aFields['nLatitud']  		   = new InputText( 'Latitud', 'nLatitud');
			$this->aFields['nLongitud']  			= new InputText( 'Longitud', 'nLongitud');
			
			$this->aFields['cCasilla']->setEmptyText('Casilla de correo postal');
			$this->aFields['cTelefono']->setHelp('Formato del campo telefono es #### #### (Interno)');
			$this->aFields['cTelefono']->setInput( new InputText() );
			$this->aFields['cTelefono']->setSeparator( "//");
			$this->aFields['cFax']->setInput( new InputText() );
			$this->aFields['cFax']->setSeparator( "//");
		// Si Viene la Ubicacion Geografica => Setea el resto de los datos
			if ( $this->aFields['ncUbicacion']->getValue() )
			{
				list ( $ncPais , $ncUbicacion ) = explode( "|", $this->aFields['ncUbicacion']->getValue()  );
				$this->setUbicacion ( $ncPais , $ncUbicacion );
			}
		// Si viene un Domicilio Busca los datos
			if ( $ncDomicilio  )
			{
				$this->setValue( $ncDomicilio );
			}
		}
	function setLevel( $nLevel)
		{
			switch ( $nLevel )
			{
				case 1:
					$this->aInput = array( 'ncUbicacion', 'cCalle', 'cPrefijoTelefono', 'cTelefono' , 'nLatitud');
					break;
			}
		}
	function setUbicacionPadre ( $ncPais, $ncUbicacion )
		{
			$cUbicacion = $this->aFields['ncUbicacion']->getValue();
			$this->aFields['ncUbicacion'] = new InputList ( "Ubicacion", "ncUbicacion" , $cUbicacion );
			//$this->aFields['ncUbicacion']->setColValueMatrix( array(0,1, 2, 3) );
			//$this->aFields['ncUbicacion']->setColDescriptionMatrix( array(4) );
			$this->aFields['ncUbicacion']->setColValueMatrix( array(0,1) );
			$this->aFields['ncUbicacion']->setColDescriptionMatrix( array(2) );
			$cSql = "SELECT ncPais, ncUbicacion, cdUbicacion
									FROM acUbicacion
										WHERE ncPais = $ncPais
											AND ncUbicacionPadre = $ncUbicacion";
			$this->aFields['ncUbicacion']->setMatrix( $this->oDatabase->getMatrix( $cSql ) ) ;
			$this->aFields['ncUbicacion']->setValue( $cUbicacion) ;
		}
	function setUbicacion ( $ncPais, $ncUbicacion )
		{
			$this->aFields['ncUbicacion']->setDescription('');
			if ( $ncUbicacion == '' || ! is_numeric ( $ncUbicacion )  ) return false;
			// Busca los datos de la Ubicacion
			$cSql = "SELECT cdUbicacion, cPrefijoTelefono, cPostal FROM acUbicacion WHERE ncPais = $ncPais AND ncUbicacion = ". $ncUbicacion;
			list( $cdUbicacion, $cPrefijoTelefono, $cPostal ) = $this->oDatabase->getArray( $cSql );
			// Actualiza los campos si estan vacios
				$this->aFields['ncPais']->setValue( $ncPais );
				if ( $this->aFields['cPrefijoTelefono']->getValue() == '' ) $this->aFields['cPrefijoTelefono']->setValue( $cPrefijoTelefono );
				if ( $this->aFields['cPostal']->getValue() == '' ) $this->aFields['cPostal']->setValue( $cPostal );
				$this->aFields['ncUbicacion']->setValue( $ncPais . '|' . $ncUbicacion );
				$this->aFields['ncUbicacion']->setDescription( $cdUbicacion );
		}
	function setValue( $ncDomicilio)
		{
			foreach ( $this->aFields as $oField )
			{
				$oField->setValue('');
			}
			if ( $ncDomicilio )
			{
				// Busca los datos de atDomicilio
				$cSql = "SELECT ncUbicacion, ncPais, cPostal, cPrefijoTelefono, cTelefono, cFax, nLatitud, nLongitud FROM atDomicilio WHERE ncDomicilio = $ncDomicilio ";
				$aDatos = $this->oDatabase->getArray( $cSql );
				$this->aFields['ncPais']->setValue( $aDatos['ncPais'] );
				$this->aFields['cPostal']->setValue( $aDatos['cPostal'] );
				$this->aFields['cPrefijoTelefono']->setValue( $aDatos['cPrefijoTelefono'] );
				$this->aFields['cTelefono']->setValue( $aDatos['cTelefono'] );
				$this->aFields['cFax']->setValue( $aDatos['cFax'] );
				$this->aFields['nLatitud']->setValue( $aDatos['nLatitud'] );
				$this->aFields['nLongitud']->setValue( $aDatos['nLongitud'] );
				$this->setUbicacion ( $aDatos['ncPais'], $aDatos['ncUbicacion'] );
				$this->aFields['ncDomicilio']->setValue( $ncDomicilio );
				// Si es Urbano Busca de atDomicilioUrbano
				$cSql = "SELECT cCalle, cCalleInterseccion, nNumero, cTorre, cPiso, cDepto FROM atDomicilioUrbano WHERE ncDomicilio = $ncDomicilio ";
				$aDatos = $this->oDatabase->getArray( $cSql );
				if ( $aDatos )
				{
					$this->aFields['nTipoDomicilio']->setValue(  DOMICILIO_URBANO );
					$this->aFields['nTipoDomicilioAnterior']->setValue(  DOMICILIO_URBANO );
					$this->aFields['cCalle']->setValue( $aDatos['cCalle'] );
					$this->aFields['cCalleInterseccion']->setValue( $aDatos['cCalleInterseccion'] );
					$this->aFields['cCalleInterseccion']->setDescription( $aDatos['cCalleInterseccion'] );
					$this->aFields['nNumero']->setValue( $aDatos['nNumero'] );
					$this->aFields['cTorre']->setValue( $aDatos['cTorre'] );
					$this->aFields['cPiso']->setValue( $aDatos['cPiso'] );
					$this->aFields['cDepto']->setValue( $aDatos['cDepto'] );
				} else
				{
					// Sino Busca si es Rural en atDomicilioRural
					$cSql = "SELECT cCalleA, cCalleB, cCalleC, cCalleD FROM atDomicilioZona WHERE ncDomicilio = $ncDomicilio ";
					$aDatos = $this->oDatabase->getArray( $cSql );
					if ( $aDatos )
					{
						$this->aFields['nTipoDomicilio']->setValue(  DOMICILIO_ZONA );
						$this->aFields['nTipoDomicilioAnterior']->setValue(  DOMICILIO_ZONA );
						$this->aFields['cCalleA']->setValue( $aDatos['cCalleA'] );
						$this->aFields['cCalleB']->setValue( $aDatos['cCalleB'] );
						$this->aFields['cCalleC']->setValue( $aDatos['cCalleC'] );
						$this->aFields['cCalleD']->setValue( $aDatos['cCalleD'] );
					} else
					{
						// Sino Busca si es Rural en atDomicilioRural
						$cSql = "SELECT ncRuta, nKilometro FROM atDomicilioRural WHERE ncDomicilio = $ncDomicilio ";
						$aDatos = $this->oDatabase->getArray( $cSql );
						if ( $aDatos )
						{
							$this->aFields['nTipoDomicilio']->setValue(  DOMICILIO_RURAL );
							$this->aFields['nTipoDomicilioAnterior']->setValue(  DOMICILIO_RURAL );
							$this->aFields['ncRuta']->setValue( $aDatos['ncRuta'] );
							$this->aFields['nKilometro']->setValue( $aDatos['nKilometro'] );
						} else
						{
							// Sino es un domicilio Postal
							$cSql = "SELECT cCasilla FROM atDomicilioPostal WHERE ncDomicilio = $ncDomicilio ";
							$cCasilla = $this->oDatabase->getData( $cSql );
							if ( $cCasilla )
							{
								$this->aFields['nTipoDomicilio']->setValue( DOMICILIO_POSTAL );
								$this->aFields['nTipoDomicilioAnterior']->setValue(  DOMICILIO_POSTAL );
								$this->aFields['cCasilla']->setValue( $cCasilla );
							} else
							{
								// Sino es un domicilio Suburbano
								$cSql = "SELECT cDescripcion  FROM atDomicilioSuburbano WHERE ncDomicilio = $ncDomicilio ";
								$cDescripcion = $this->oDatabase->getData( $cSql );
								if ( $cDescripcion )
								{
									$this->aFields['nTipoDomicilio']->setValue( DOMICILIO_SUBURBANO );
									$this->aFields['nTipoDomicilioAnterior']->setValue(  DOMICILIO_SUBURBANO );
									$this->aFields['cDescripcion']->setValue( $cDescripcion );
								}
							}
						}
					}
				}
			}
		}
	function makeDomicilio ( $nTipoDomicilio = '')
		{
			$this->aFields['cTelefono']->setForm( $this );
			$this->aFields['cTelefono']->setWidth( 160 );
			$this->aFields['cPostales']->setOnChange("oPostal = eval(\"document.". $this->getFormName()  . ".cPostal\" ); oPostal.value = this.value; ");
			$this->aFields['cFax']->setForm( $this );
			$this->aFields['cFax']->setWidth( 160 );
			if ( $nTipoDomicilio == '' ) $nTipoDomicilio = getParam( 'nTipoDomicilio' );
			switch( $nTipoDomicilio )
			{
				case DOMICILIO_ZONA:
					$this->aFields['cCalleA']->setLength(60);
					$this->aFields['cCalleB']->setLength(60);
					$this->aFields['cCalleC']->setLength(60);
					$this->aFields['cCalleD']->setLength(60);
					$this->aFields['cCalleA']->setForm( $this );
					$this->aFields['cCalleB']->setForm( $this );
					$this->aFields['cCalleC']->setForm( $this );
					$this->aFields['cCalleD']->setForm( $this );
					$cUrl = URL_ROOT . '?' . PARAM_REFRESH . '=class&amp;' . PARAM_MODULE . '=administracion&amp;' . PARAM_ACTION . '=' . BUSCAR_CALLES . '&amp;' . PARAM_CLASS . '=calle_lst&amp;' . PARAM_METHOD . '=getData';
					$this->aFields['cCalleA']->setEditable ( $cUrl );
					$this->aFields['cCalleB']->setEditable ( $cUrl );
					$this->aFields['cCalleC']->setEditable ( $cUrl );
					$this->aFields['cCalleD']->setEditable ( $cUrl );
					?>
					
						<div style="width: 380px; position: relative;">
							<div style="width: 190px; float: left;"><?= $this->aFields['cCalleA']->showLabel(); ?></div>
							<div style="width: 190px; float: left;"><?= $this->aFields['cCalleB']->showLabel(); ?></div>
							<div style="width: 190px; float: left;"><?= $this->aFields['cCalleA']->make(); ?></div>
							<div style="width: 190px; float: left;"><?= $this->aFields['cCalleB']->make(); ?></div>
							<div style="width: 190px; float: left;"><?= $this->aFields['cCalleC']->showLabel(); ?></div>
							<div style="width: 190px; float: left;"><?= $this->aFields['cCalleD']->showLabel(); ?></div>
							<div style="width: 190px; float: left;"><?= $this->aFields['cCalleC']->make(); ?></div>
							<div style="width: 190px; float: left;"><?= $this->aFields['cCalleD']->make(); ?></div>
							<div style="clear:both;"></div>
						</div>
					<?
					break;
				case DOMICILIO_RURAL:
					$this->aFields['nKilometro']->setLength(5);
					$this->aFields['ncRuta']->setMandatory( $this->isMandatory() );
					$this->aFields['ncRuta']->addColDescription( 2);
					$this->aFields['ncRuta']->addColDescription( 3);
					$cSql = "SELECT ncRuta, TRu.cAbreviatura, Jur.cAbreviatura, cdRuta
											FROM acRuta as Rut
												JOIN acTipoRuta as TRu
													ON TRu.ncTipoRuta = Rut.ncTipoRuta
												JOIN acJurisdiccion as Jur
													ON Jur.ncJurisdiccion= Rut.ncJurisdiccion";
					$this->aFields['ncRuta']->setMatrix( $this->oDatabase->getMatrix( $cSql ) ) ;
					?>
					<table style="height:40px" border="0" cellspacing="0">
							<tr>
								<td>
									<?= $this->aFields['ncRuta']->showLabel(); ?>
								</td>
								<td>
									<?= $this->aFields['nKilometro']->showLabel(); ?>
								</td>
							</tr>
							<tr>
								<td>
									<?= $this->aFields['ncRuta']->make(); ?>
								</td>
								<td>
									<?= $this->aFields['nKilometro']->make(); ?>
								</td>
							</tr>
						</table>
					<?
					break;
				case DOMICILIO_SUBURBANO:
					$this->aFields['cDescripcion']->setLength(250);
					$this->aFields['cDescripcion']->setWidth(400);
					$this->aFields['cDescripcion']->setMandatory( $this->isMandatory() );
					?>
					<table style="height:40px"  border="0" cellspacing="0">
<!--						<tr>
							<td>
								<?= $this->aFields['cDescripcion']->showLabel(); ?><br/>
							</td>
						</tr>
-->
						<tr>
							<td>
							<?= $this->aFields['cDescripcion']->make(); ?>
							</td>
						</tr>
					</table>
					<?
					break;
				case DOMICILIO_POSTAL:
					$this->aFields['cCasilla']->setLength(20);
					$this->aFields['cCasilla']->setWidth(180);
					$this->aFields['cCasilla']->setMandatory( $this->isMandatory() );
					?>
					<table style="height:40px"  border="0" cellspacing="0">
						<tr>
							<td>
							<?= $this->aFields['cCasilla']->make(); ?>
							</td>
						</tr>
					</table>
					<?
					break;
				case DOMICILIO_URBANO:
					$this->aFields['cCalle']->setLength(60);
					$this->aFields['cCalle']->setForm( $this );
					$cUrl = URL_ROOT . '?' . PARAM_REFRESH . '=class&amp;' . PARAM_MODULE . '=administracion&amp;' . PARAM_ACTION . '=' . BUSCAR_CALLES . '&amp;' . PARAM_CLASS . '=calle_lst&amp;' . PARAM_METHOD . '=getData';
					$this->aFields['cCalle']->setEditable ( $cUrl );
					
					//$this->aFields['cCalleInterseccion']->setLength(60);
					$this->aFields['cCalleInterseccion']->setWidth(150);
					$this->aFields['cCalleInterseccion']->setForm( $this );
					$cUrl = URL_ROOT . '?' . PARAM_REFRESH . '=class&amp;' . PARAM_MODULE . '=administracion&amp;' . PARAM_ACTION . '=' . BUSCAR_CALLES . '&amp;' . PARAM_CLASS . '=calle_lst&amp;' . PARAM_METHOD . '=getData';
					$this->aFields['cCalleInterseccion']->setEditable ( $cUrl );

					$this->aFields['nNumero']->setLength(5);
					$this->aFields['cTorre']->setLength(7);
					$this->aFields['cTorre']->setWidth(30);
					$this->aFields['cPiso']->setLength(5);
					$this->aFields['cPiso']->setWidth(30);
					$this->aFields['cDepto']->setLength(5);
					$this->aFields['cDepto']->setWidth(30);
					?>
						<div style="width: 370px; position: relative;">
							<div style="width: 190px; float: left;"><?= $this->aFields['cCalle']->showLabel(); ?></div>
							<div style="width: 50px; float: left;"><?= $this->aFields['nNumero']->showLabel(); ?></div>
							<div style="width: 40px; float: left;"><?= $this->aFields['cTorre']->showLabel(); ?></div>
							<div style="width: 40px; float: left;"><?= $this->aFields['cPiso']->showLabel(); ?></div>
							<div style="width: 40px; float: left;"><?= $this->aFields['cDepto']->showLabel(); ?></div>
							<div style="width: 190px; float: left;"><?= $this->aFields['cCalle']->make(); ?></div>
							<div style="width: 50px; float: left;"><?= $this->aFields['nNumero']->make(); ?></div>
							<div style="width: 40px; float: left;"><?= $this->aFields['cTorre']->make(); ?></div>
							<div style="width: 40px; float: left;"><?= $this->aFields['cPiso']->make(); ?></div>
							<div style="width: 40px; float: left;"><?= $this->aFields['cDepto']->make(); ?></div>
							<div style="clear:both;"></div>
						</div>
					<?
				break;
			}
		}
	function setOptions( $cOption )
		{
			backtrace();
		}
	function makeFields()
		{
			//Configura los Campos de Edicion
				$this->aFields['nTipoDomicilio']->setOptions( 'R' );
				$this->aFields['nTipoDomicilio']->setDefault( DOMICILIO_URBANO );
				$this->aFields['nTipoDomicilio']->addOption ( DOMICILIO_URBANO, 'Urbano' );
				$this->aFields['nTipoDomicilio']->addOption ( DOMICILIO_ZONA, 'Zona' );
				$this->aFields['nTipoDomicilio']->addOption ( DOMICILIO_POSTAL, 'Postal' );
				$this->aFields['nTipoDomicilio']->addOption ( DOMICILIO_SUBURBANO, 'Suburbano' );
				$this->aFields['nTipoDomicilio']->addOption ( DOMICILIO_RURAL, 'Rural' );
				$this->aFields['nTipoDomicilio']->setOnChange( $cJavaScript );
				if ( MODO_AJAX == true  )
				{
					$cUrl = '?' . PARAM_MODULE . '=administracion&amp;' . PARAM_REFRESH . '=class&amp;' . PARAM_ACTION . '=' . MODIFICAR_DOMICILIO . '&amp;' . PARAM_SUBMODULE . '=entidades&amp;' . PARAM_CLASS . '=domicilio_frm&amp;' . PARAM_METHOD . "=makeDomicilio&amp;nTipoDomicilio=\" + this.value" ;
					$cOnChange = "return send( \"$cUrl, refreshElement, \"subtipo_domicilio\" );";
					$this->aFields['nTipoDomicilio']->setOnChange( $cOnChange );
				}
				$this->aFields['ncDomicilio']->setHidden();
				$this->aFields['nTipoDomicilioAnterior']->setHidden();
				$this->aFields['cPostal']->setLength(10);
				$this->aFields['cPrefijoTelefono']->setHelp('Formato del campo es prefijo nacional y prefijo local tipo ## ### sin ( y +, por ej 54 11.');
				$this->aFields['cPrefijoTelefono']->setLength(10);
				$this->aFields['cPrefijoTelefono']->setSize(5);
				// Configura Ubicacion

				$this->aFields['ncUbicacion']->setMandatory( $this->isMandatory() );
				$this->aFields['ncUbicacion']->setForm( $this );

				if ( get_class($this->aFields['ncUbicacion']) == 'InputLookUp' )
				{
					$cUrl = URL_ROOT . '?' . PARAM_REFRESH . '=class&amp;' . PARAM_MODULE . '=administracion&amp;' . PARAM_ACTION . '=' . BUSCAR_UBICACIONES . '&amp;' . PARAM_CLASS . '=ubicacion_lst&amp;' . PARAM_METHOD . '=getData';
					$this->aFields['ncUbicacion']->setEditable( $cUrl );
					$cJavaScript = "oKey    = eval(\"document.". $this->getFormName() . ".ncUbicacion_Key\");
											oPostal           = eval(\"document.". $this->getFormName() . ".cPostal\" );
											oPrefijoTelefono  = eval(\"document.". $this->getFormName() . ".cPrefijoTelefono\" );
											cKeyValue = oKey.value;
											nPos = cKeyValue.indexOf(\"|\");
											nPos1 = cKeyValue.indexOf(\"|\", nPos+1);
											nPos2 = cKeyValue.indexOf(\"|\", nPos1+1);
											nPos3 = cKeyValue.indexOf(\"|\", nPos2+1);
											if ( nPos2 != -1 &amp;&amp; nPos2 > nPos1 + 1 )
											{
												cCodigo = cKeyValue.substring ( nPos1 + 1 , nPos2 );
												oPostales = eval(\"document.". $this->getFormName() . ".cPostales\" );
												aPostales = cCodigo.split( \",\" );
												oPostales.length = 1;
												for( nIndex = 0; nIndex < aPostales.length; nIndex++ )
												{
													oOption = new Option( aPostales[nIndex], aPostales[nIndex] );
													oPostales.add(oOption, null );
												}
											}
											if ( nPos3 > nPos2 + 1 ) oPrefijoTelefono.value = cKeyValue.substring ( nPos2 + 1, nPos3 );
											nPos4 = cKeyValue.indexOf(\"|\", nPos3+1);
											nPos5 = cKeyValue.length;
											oKey.value = cKeyValue.substring ( 0, nPos1 );
											oReferencia       = document.getElementById( \"celReferencia\");
											oDesc             = eval(\"document.". $this->getFormName() . ".ncUbicacion_Desc\" );
											if ( nPos4 > nPos3 + 1 ) oReferencia.innerHTML = cKeyValue.substring ( nPos3 + 1, nPos4 );
											if ( nPos5 > nPos4 + 1 ) oDesc.value = cKeyValue.substring ( nPos4 + 1, nPos5 );
												";
					$this->aFields['ncUbicacion']->addActionArray( 2, $this->oModule->getActionArray( BUSCAR_UBICACIONES ) );
					$this->aFields['ncUbicacion']->setOnChange( $cJavaScript );
				} else
				{
					$cJavaScript = "oKey    = eval(\"document.". $this->getFormName() . ".ncUbicacion\");
											oPostal           = eval(\"document.". $this->getFormName() . ".cPostal\" );
											oPrefijoTelefono  = eval(\"document.". $this->getFormName() . ".cPrefijoTelefono\" );
											cKeyValue = oKey.value;
											nPos = cKeyValue.indexOf(\"|\");
											nPos1 = cKeyValue.indexOf(\"|\", nPos+1);
											nPos2 = cKeyValue.indexOf(\"|\", nPos1+1);
											nPos3 = cKeyValue.length;
											if ( nPos2 != -1 &amp;&amp; nPos2 > nPos1 + 1 )
											{
												cCodigo = cKeyValue.substring ( nPos1 + 1 , nPos2 );
												oPostales = eval(\"document.". $this->getFormName() . ".cPostales\" );
												aPostales = cCodigo.split( \",\" );
												oPostales.length = 1;
												for( nIndex = 0; nIndex < aPostales.length; nIndex++ )
												{
													oOption = new Option( aPostales[nIndex], aPostales[nIndex] );
													oPostales.add(oOption, null );
												}
											}
											if ( nPos3 > nPos2 + 1 ) oPrefijoTelefono.value = cKeyValue.substring ( nPos2 + 1, nPos3 );";
					//$this->aFields['ncUbicacion']->setOnChange( $cJavaScript );
				}
				$this->aFields['ncUbicacion']->addActionArray( 2, $this->oModule->getActionArray( AGREGAR_UNA_UBICACION ), "" );
				$this->aFields['ncUbicacion']->addActionArray( 3, $this->oModule->getActionArray( MODIFICAR_UNA_UBICACION ), "" );

			// Si viene un Domicilio Busca los datos
			if ( $ncDomicilio  )
			{
				$this->setValue( $ncDomicilio );
			}
			// Si No tiene Ubicacion Geografica => Setea una Por Omision
			/*
			if ( $this->aFields['ncUbicacion']->getValue() == '' )
			{
				$this->setUbicacion ( UBICACION_GEOGRAFICA_PAIS_DEFAULT, UBICACION_GEOGRAFICA_LUGAR_DEFAULT );
			}
			*/
			if ( $this->cOptions{0} == 'T'  )
			{
				?><form name="<?= $this->getFormName () ?>" onSubmit="return checkForm(this);" method="post" action="<?= $this->oModule->getActionForm(); ?>" ><?
			}
			?>
				<p>
					<?= $this->aFields['nTipoDomicilio']->make(); ?>
				</p>
				<div id='subtipo_domicilio'>
					<? $this->makeDomicilio ( $this->aFields['nTipoDomicilio']->getValue() );   ?>
				</div>
				<?= $this->aFields['ncDomicilio']->make(); ?>
				<?= $this->aFields['nTipoDomicilioAnterior']->make(); ?>
				<p>
					<?= $this->aFields['ncUbicacion']->showLabel(); ?><br/>
					<?= $this->aFields['ncUbicacion']->make(); ?>
					<?= $this->aFields['ncUbicacion']->showActions(); ?>
				</p>
				<p>					
					<?= $this->aFields['nLatitud']->showLabel(); ?><?= $this->aFields['nLatitud']->make(); ?>
				</p>
				<p>
					<?= $this->aFields['nLongitud']->showLabel(); ?><?= $this->aFields['nLongitud']->make(); ?>
				</p>
				<table border="0" cellspacing="0">
					<tr>
						<td>
							<?= $this->aFields['cPostal']->showLabel(); ?><br/>
						</td>
						<td>Referencia
						</td>
					</tr>
					<tr>
						<td id='CeldaPostal' >
							<?= $this->aFields['cPostal']->make(); ?>
							<?= $this->aFields['cPostales']->make(); ?>
						</td>
						<td id="celReferencia">
						</td>
					</tr>
				</table>
				<div style="width: 520px; position: relative;">
					<div style="width: 80px; float: left;"><?= $this->aFields['cPrefijoTelefono']->showLabel(); ?></div>
					<div style="width: 220px; float: left;"><?= $this->aFields['cTelefono']->showLabel(); ?></div>
					<div style="width: 220px; float: left;"><?= $this->aFields['cFax']->showLabel(); ?></div>
					<div style="width: 80px; float: left; padding-top: 30px; vertical-align: middle;">(<?= $this->aFields['cPrefijoTelefono']->make(); ?>)</div>
					<div style="width: 220px; float: left;"><?= $this->aFields['cTelefono']->make(); ?></div>
					<div style="width: 220px; float: left;"><?= $this->aFields['cFax']->make(); ?></div>
					<div style="clear:both;"></div>
				</div>
			<? if ( $this->cOptions{0} == 'T'  ) { ?>
				</form>
			<? } ?>
			<?
		}
	}
?>